package com.funong.matrix.biz.power.domain;


import com.funong.matrix.biz.base.dao.SysRoleMenuDao;
import com.funong.matrix.biz.base.dao.SysRolePermissionDao;
import com.funong.matrix.biz.power.pojo.dto.SysRoleAuthDTO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 角色
 *
 * @author lincl
 */
@Service
public class SysRoleDomainDao {

    @Resource
    private SysRoleMenuDao sysRoleMenuDao;

    @Resource
    private SysRolePermissionDao sysRolePermissionDao;

    /**
     * 角色授权
     *
     * @param sysRoleAuthDTO
     */
    public void saveRoleAuth(SysRoleAuthDTO sysRoleAuthDTO) {
        // 菜单
        sysRoleMenuDao.deleteRoleMenu(sysRoleAuthDTO.getRoleCode());
        sysRoleMenuDao.saveRoleMenu(sysRoleAuthDTO.getRoleCode(), sysRoleAuthDTO.getMenuCodeList());
        // 角色
        sysRolePermissionDao.deleteRolePermission(sysRoleAuthDTO.getRoleCode());
        sysRolePermissionDao.saveRolePermission(sysRoleAuthDTO.getRoleCode(), sysRoleAuthDTO.getPermissionCodeList());
    }
}
